// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyCurveAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>
#include <visit-config.h>
#include <ColorAttribute.h>
#include <ColorAttribute.h>
#include <ColorAttribute.h>
#include <ColorAttribute.h>
#include <ColorAttribute.h>

// ****************************************************************************
// Module: PyCurveAttributes
//
// Purpose:
//   Attributes for the xy plot
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a CurveAttributes.
//
struct CurveAttributesObject
{
    PyObject_HEAD
    CurveAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewCurveAttributes(int);
std::string
PyCurveAttributes_ToString(const CurveAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    if(atts->GetShowLines())
        snprintf(tmpStr, 1000, "%sshowLines = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowLines = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%slineWidth = %d\n", prefix, atts->GetLineWidth());
    str += tmpStr;
    if(atts->GetShowPoints())
        snprintf(tmpStr, 1000, "%sshowPoints = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowPoints = 0\n", prefix);
    str += tmpStr;
    const char *symbol_names = "Point, TriangleUp, TriangleDown, Square, Circle, "
        "Plus, X";
    switch (atts->GetSymbol())
    {
      case CurveAttributes::Point:
          snprintf(tmpStr, 1000, "%ssymbol = %sPoint  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      case CurveAttributes::TriangleUp:
          snprintf(tmpStr, 1000, "%ssymbol = %sTriangleUp  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      case CurveAttributes::TriangleDown:
          snprintf(tmpStr, 1000, "%ssymbol = %sTriangleDown  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      case CurveAttributes::Square:
          snprintf(tmpStr, 1000, "%ssymbol = %sSquare  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      case CurveAttributes::Circle:
          snprintf(tmpStr, 1000, "%ssymbol = %sCircle  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      case CurveAttributes::Plus:
          snprintf(tmpStr, 1000, "%ssymbol = %sPlus  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      case CurveAttributes::X:
          snprintf(tmpStr, 1000, "%ssymbol = %sX  # %s\n", prefix, prefix, symbol_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    snprintf(tmpStr, 1000, "%spointSize = %g\n", prefix, atts->GetPointSize());
    str += tmpStr;
    const char *pointFillMode_names = "Static, Dynamic";
    switch (atts->GetPointFillMode())
    {
      case CurveAttributes::Static:
          snprintf(tmpStr, 1000, "%spointFillMode = %sStatic  # %s\n", prefix, prefix, pointFillMode_names);
          str += tmpStr;
          break;
      case CurveAttributes::Dynamic:
          snprintf(tmpStr, 1000, "%spointFillMode = %sDynamic  # %s\n", prefix, prefix, pointFillMode_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    snprintf(tmpStr, 1000, "%spointStride = %d\n", prefix, atts->GetPointStride());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%ssymbolDensity = %d\n", prefix, atts->GetSymbolDensity());
    str += tmpStr;
    const char *curveColorSource_names = "Cycle, Custom";
    switch (atts->GetCurveColorSource())
    {
      case CurveAttributes::Cycle:
          snprintf(tmpStr, 1000, "%scurveColorSource = %sCycle  # %s\n", prefix, prefix, curveColorSource_names);
          str += tmpStr;
          break;
      case CurveAttributes::Custom:
          snprintf(tmpStr, 1000, "%scurveColorSource = %sCustom  # %s\n", prefix, prefix, curveColorSource_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const unsigned char *curveColor = atts->GetCurveColor().GetColor();
    snprintf(tmpStr, 1000, "%scurveColor = (%d, %d, %d, %d)\n", prefix, int(curveColor[0]), int(curveColor[1]), int(curveColor[2]), int(curveColor[3]));
    str += tmpStr;
    if(atts->GetShowLegend())
        snprintf(tmpStr, 1000, "%sshowLegend = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowLegend = 0\n", prefix);
    str += tmpStr;
    if(atts->GetShowLabels())
        snprintf(tmpStr, 1000, "%sshowLabels = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowLabels = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sdesignator = \"%s\"\n", prefix, atts->GetDesignator().c_str());
    str += tmpStr;
    if(atts->GetDoBallTimeCue())
        snprintf(tmpStr, 1000, "%sdoBallTimeCue = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sdoBallTimeCue = 0\n", prefix);
    str += tmpStr;
    const unsigned char *ballTimeCueColor = atts->GetBallTimeCueColor().GetColor();
    snprintf(tmpStr, 1000, "%sballTimeCueColor = (%d, %d, %d, %d)\n", prefix, int(ballTimeCueColor[0]), int(ballTimeCueColor[1]), int(ballTimeCueColor[2]), int(ballTimeCueColor[3]));
    str += tmpStr;
    snprintf(tmpStr, 1000, "%stimeCueBallSize = %g\n", prefix, atts->GetTimeCueBallSize());
    str += tmpStr;
    if(atts->GetDoLineTimeCue())
        snprintf(tmpStr, 1000, "%sdoLineTimeCue = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sdoLineTimeCue = 0\n", prefix);
    str += tmpStr;
    const unsigned char *lineTimeCueColor = atts->GetLineTimeCueColor().GetColor();
    snprintf(tmpStr, 1000, "%slineTimeCueColor = (%d, %d, %d, %d)\n", prefix, int(lineTimeCueColor[0]), int(lineTimeCueColor[1]), int(lineTimeCueColor[2]), int(lineTimeCueColor[3]));
    str += tmpStr;
    snprintf(tmpStr, 1000, "%slineTimeCueWidth = %d\n", prefix, atts->GetLineTimeCueWidth());
    str += tmpStr;
    if(atts->GetDoCropTimeCue())
        snprintf(tmpStr, 1000, "%sdoCropTimeCue = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sdoCropTimeCue = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%stimeForTimeCue = %g\n", prefix, atts->GetTimeForTimeCue());
    str += tmpStr;
    const char *fillMode_names = "NoFill, Solid, HorizontalGradient, VerticalGradient";
    switch (atts->GetFillMode())
    {
      case CurveAttributes::NoFill:
          snprintf(tmpStr, 1000, "%sfillMode = %sNoFill  # %s\n", prefix, prefix, fillMode_names);
          str += tmpStr;
          break;
      case CurveAttributes::Solid:
          snprintf(tmpStr, 1000, "%sfillMode = %sSolid  # %s\n", prefix, prefix, fillMode_names);
          str += tmpStr;
          break;
      case CurveAttributes::HorizontalGradient:
          snprintf(tmpStr, 1000, "%sfillMode = %sHorizontalGradient  # %s\n", prefix, prefix, fillMode_names);
          str += tmpStr;
          break;
      case CurveAttributes::VerticalGradient:
          snprintf(tmpStr, 1000, "%sfillMode = %sVerticalGradient  # %s\n", prefix, prefix, fillMode_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const unsigned char *fillColor1 = atts->GetFillColor1().GetColor();
    snprintf(tmpStr, 1000, "%sfillColor1 = (%d, %d, %d, %d)\n", prefix, int(fillColor1[0]), int(fillColor1[1]), int(fillColor1[2]), int(fillColor1[3]));
    str += tmpStr;
    const unsigned char *fillColor2 = atts->GetFillColor2().GetColor();
    snprintf(tmpStr, 1000, "%sfillColor2 = (%d, %d, %d, %d)\n", prefix, int(fillColor2[0]), int(fillColor2[1]), int(fillColor2[2]), int(fillColor2[3]));
    str += tmpStr;
    if(atts->GetPolarToCartesian())
        snprintf(tmpStr, 1000, "%spolarToCartesian = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%spolarToCartesian = 0\n", prefix);
    str += tmpStr;
    const char *polarCoordinateOrder_names = "R_Theta, Theta_R";
    switch (atts->GetPolarCoordinateOrder())
    {
      case CurveAttributes::R_Theta:
          snprintf(tmpStr, 1000, "%spolarCoordinateOrder = %sR_Theta  # %s\n", prefix, prefix, polarCoordinateOrder_names);
          str += tmpStr;
          break;
      case CurveAttributes::Theta_R:
          snprintf(tmpStr, 1000, "%spolarCoordinateOrder = %sTheta_R  # %s\n", prefix, prefix, polarCoordinateOrder_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    const char *angleUnits_names = "Radians, Degrees";
    switch (atts->GetAngleUnits())
    {
      case CurveAttributes::Radians:
          snprintf(tmpStr, 1000, "%sangleUnits = %sRadians  # %s\n", prefix, prefix, angleUnits_names);
          str += tmpStr;
          break;
      case CurveAttributes::Degrees:
          snprintf(tmpStr, 1000, "%sangleUnits = %sDegrees  # %s\n", prefix, prefix, angleUnits_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    return str;
}

static PyObject *
CurveAttributes_Notify(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_SetShowLines(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showLines in the object.
    obj->data->SetShowLines(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetShowLines(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowLines()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetLineWidth(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the lineWidth in the object.
    obj->data->SetLineWidth(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetLineWidth(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetLineWidth()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetShowPoints(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showPoints in the object.
    obj->data->SetShowPoints(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetShowPoints(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowPoints()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetSymbol(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 7)
    {
        std::stringstream ss;
        ss << "An invalid symbol value was given." << std::endl;
        ss << "Valid values are in the range [0,6]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Point";
        ss << ", TriangleUp";
        ss << ", TriangleDown";
        ss << ", Square";
        ss << ", Circle";
        ss << ", Plus";
        ss << ", X";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the symbol in the object.
    obj->data->SetSymbol(CurveAttributes::SymbolTypes(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetSymbol(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetSymbol()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetPointSize(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the pointSize in the object.
    obj->data->SetPointSize(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetPointSize(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetPointSize());
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetPointFillMode(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid pointFillMode value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Static";
        ss << ", Dynamic";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the pointFillMode in the object.
    obj->data->SetPointFillMode(CurveAttributes::FillMode(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetPointFillMode(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetPointFillMode()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetPointStride(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the pointStride in the object.
    obj->data->SetPointStride(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetPointStride(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetPointStride()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetSymbolDensity(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the symbolDensity in the object.
    obj->data->SetSymbolDensity(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetSymbolDensity(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetSymbolDensity()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetCurveColorSource(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid curveColorSource value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Cycle";
        ss << ", Custom";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the curveColorSource in the object.
    obj->data->SetCurveColorSource(CurveAttributes::CurveColor(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetCurveColorSource(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetCurveColorSource()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetCurveColor(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
    {
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
        {
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
            }
        }
        PyErr_Clear();
    }

    // Set the curveColor in the object.
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
    obj->data->SetCurveColor(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetCurveColor(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the curveColor.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *curveColor = obj->data->GetCurveColor().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(curveColor[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(curveColor[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(curveColor[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(curveColor[3])));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetShowLegend(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showLegend in the object.
    obj->data->SetShowLegend(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetShowLegend(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowLegend()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetShowLabels(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showLabels in the object.
    obj->data->SetShowLabels(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetShowLabels(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowLabels()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetDesignator(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the designator in the object.
    obj->data->SetDesignator(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetDesignator(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetDesignator().c_str());
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetDoBallTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the doBallTimeCue in the object.
    obj->data->SetDoBallTimeCue(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetDoBallTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetDoBallTimeCue()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetBallTimeCueColor(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
    {
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
        {
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
            }
        }
        PyErr_Clear();
    }

    // Set the ballTimeCueColor in the object.
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
    obj->data->SetBallTimeCueColor(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetBallTimeCueColor(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the ballTimeCueColor.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *ballTimeCueColor = obj->data->GetBallTimeCueColor().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(ballTimeCueColor[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(ballTimeCueColor[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(ballTimeCueColor[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(ballTimeCueColor[3])));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetTimeCueBallSize(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the timeCueBallSize in the object.
    obj->data->SetTimeCueBallSize(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetTimeCueBallSize(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetTimeCueBallSize());
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetDoLineTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the doLineTimeCue in the object.
    obj->data->SetDoLineTimeCue(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetDoLineTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetDoLineTimeCue()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetLineTimeCueColor(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
    {
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
        {
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
            }
        }
        PyErr_Clear();
    }

    // Set the lineTimeCueColor in the object.
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
    obj->data->SetLineTimeCueColor(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetLineTimeCueColor(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the lineTimeCueColor.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *lineTimeCueColor = obj->data->GetLineTimeCueColor().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(lineTimeCueColor[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(lineTimeCueColor[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(lineTimeCueColor[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(lineTimeCueColor[3])));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetLineTimeCueWidth(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the lineTimeCueWidth in the object.
    obj->data->SetLineTimeCueWidth(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetLineTimeCueWidth(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetLineTimeCueWidth()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetDoCropTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the doCropTimeCue in the object.
    obj->data->SetDoCropTimeCue(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetDoCropTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetDoCropTimeCue()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetTimeForTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the timeForTimeCue in the object.
    obj->data->SetTimeForTimeCue(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetTimeForTimeCue(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetTimeForTimeCue());
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetFillMode(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 4)
    {
        std::stringstream ss;
        ss << "An invalid fillMode value was given." << std::endl;
        ss << "Valid values are in the range [0,3]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " NoFill";
        ss << ", Solid";
        ss << ", HorizontalGradient";
        ss << ", VerticalGradient";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the fillMode in the object.
    obj->data->SetFillMode(CurveAttributes::CurveFillMode(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetFillMode(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetFillMode()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetFillColor1(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
    {
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
        {
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
            }
        }
        PyErr_Clear();
    }

    // Set the fillColor1 in the object.
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
    obj->data->SetFillColor1(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetFillColor1(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the fillColor1.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *fillColor1 = obj->data->GetFillColor1().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(fillColor1[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(fillColor1[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(fillColor1[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(fillColor1[3])));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetFillColor2(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
    {
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
        {
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
            }
        }
        PyErr_Clear();
    }

    // Set the fillColor2 in the object.
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
    obj->data->SetFillColor2(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetFillColor2(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the fillColor2.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *fillColor2 = obj->data->GetFillColor2().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(fillColor2[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(fillColor2[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(fillColor2[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(fillColor2[3])));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetPolarToCartesian(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the polarToCartesian in the object.
    obj->data->SetPolarToCartesian(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetPolarToCartesian(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetPolarToCartesian()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetPolarCoordinateOrder(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid polarCoordinateOrder value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " R_Theta";
        ss << ", Theta_R";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the polarCoordinateOrder in the object.
    obj->data->SetPolarCoordinateOrder(CurveAttributes::PolarCoordinateOrder(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetPolarCoordinateOrder(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetPolarCoordinateOrder()));
    return retval;
}

/*static*/ PyObject *
CurveAttributes_SetAngleUnits(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 2)
    {
        std::stringstream ss;
        ss << "An invalid angleUnits value was given." << std::endl;
        ss << "Valid values are in the range [0,1]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Radians";
        ss << ", Degrees";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the angleUnits in the object.
    obj->data->SetAngleUnits(CurveAttributes::AngleUnits(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CurveAttributes_GetAngleUnits(PyObject *self, PyObject *args)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetAngleUnits()));
    return retval;
}



PyMethodDef PyCurveAttributes_methods[CURVEATTRIBUTES_NMETH] = {
    {"Notify", CurveAttributes_Notify, METH_VARARGS},
    {"SetShowLines", CurveAttributes_SetShowLines, METH_VARARGS},
    {"GetShowLines", CurveAttributes_GetShowLines, METH_VARARGS},
    {"SetLineWidth", CurveAttributes_SetLineWidth, METH_VARARGS},
    {"GetLineWidth", CurveAttributes_GetLineWidth, METH_VARARGS},
    {"SetShowPoints", CurveAttributes_SetShowPoints, METH_VARARGS},
    {"GetShowPoints", CurveAttributes_GetShowPoints, METH_VARARGS},
    {"SetSymbol", CurveAttributes_SetSymbol, METH_VARARGS},
    {"GetSymbol", CurveAttributes_GetSymbol, METH_VARARGS},
    {"SetPointSize", CurveAttributes_SetPointSize, METH_VARARGS},
    {"GetPointSize", CurveAttributes_GetPointSize, METH_VARARGS},
    {"SetPointFillMode", CurveAttributes_SetPointFillMode, METH_VARARGS},
    {"GetPointFillMode", CurveAttributes_GetPointFillMode, METH_VARARGS},
    {"SetPointStride", CurveAttributes_SetPointStride, METH_VARARGS},
    {"GetPointStride", CurveAttributes_GetPointStride, METH_VARARGS},
    {"SetSymbolDensity", CurveAttributes_SetSymbolDensity, METH_VARARGS},
    {"GetSymbolDensity", CurveAttributes_GetSymbolDensity, METH_VARARGS},
    {"SetCurveColorSource", CurveAttributes_SetCurveColorSource, METH_VARARGS},
    {"GetCurveColorSource", CurveAttributes_GetCurveColorSource, METH_VARARGS},
    {"SetCurveColor", CurveAttributes_SetCurveColor, METH_VARARGS},
    {"GetCurveColor", CurveAttributes_GetCurveColor, METH_VARARGS},
    {"SetShowLegend", CurveAttributes_SetShowLegend, METH_VARARGS},
    {"GetShowLegend", CurveAttributes_GetShowLegend, METH_VARARGS},
    {"SetShowLabels", CurveAttributes_SetShowLabels, METH_VARARGS},
    {"GetShowLabels", CurveAttributes_GetShowLabels, METH_VARARGS},
    {"SetDesignator", CurveAttributes_SetDesignator, METH_VARARGS},
    {"GetDesignator", CurveAttributes_GetDesignator, METH_VARARGS},
    {"SetDoBallTimeCue", CurveAttributes_SetDoBallTimeCue, METH_VARARGS},
    {"GetDoBallTimeCue", CurveAttributes_GetDoBallTimeCue, METH_VARARGS},
    {"SetBallTimeCueColor", CurveAttributes_SetBallTimeCueColor, METH_VARARGS},
    {"GetBallTimeCueColor", CurveAttributes_GetBallTimeCueColor, METH_VARARGS},
    {"SetTimeCueBallSize", CurveAttributes_SetTimeCueBallSize, METH_VARARGS},
    {"GetTimeCueBallSize", CurveAttributes_GetTimeCueBallSize, METH_VARARGS},
    {"SetDoLineTimeCue", CurveAttributes_SetDoLineTimeCue, METH_VARARGS},
    {"GetDoLineTimeCue", CurveAttributes_GetDoLineTimeCue, METH_VARARGS},
    {"SetLineTimeCueColor", CurveAttributes_SetLineTimeCueColor, METH_VARARGS},
    {"GetLineTimeCueColor", CurveAttributes_GetLineTimeCueColor, METH_VARARGS},
    {"SetLineTimeCueWidth", CurveAttributes_SetLineTimeCueWidth, METH_VARARGS},
    {"GetLineTimeCueWidth", CurveAttributes_GetLineTimeCueWidth, METH_VARARGS},
    {"SetDoCropTimeCue", CurveAttributes_SetDoCropTimeCue, METH_VARARGS},
    {"GetDoCropTimeCue", CurveAttributes_GetDoCropTimeCue, METH_VARARGS},
    {"SetTimeForTimeCue", CurveAttributes_SetTimeForTimeCue, METH_VARARGS},
    {"GetTimeForTimeCue", CurveAttributes_GetTimeForTimeCue, METH_VARARGS},
    {"SetFillMode", CurveAttributes_SetFillMode, METH_VARARGS},
    {"GetFillMode", CurveAttributes_GetFillMode, METH_VARARGS},
    {"SetFillColor1", CurveAttributes_SetFillColor1, METH_VARARGS},
    {"GetFillColor1", CurveAttributes_GetFillColor1, METH_VARARGS},
    {"SetFillColor2", CurveAttributes_SetFillColor2, METH_VARARGS},
    {"GetFillColor2", CurveAttributes_GetFillColor2, METH_VARARGS},
    {"SetPolarToCartesian", CurveAttributes_SetPolarToCartesian, METH_VARARGS},
    {"GetPolarToCartesian", CurveAttributes_GetPolarToCartesian, METH_VARARGS},
    {"SetPolarCoordinateOrder", CurveAttributes_SetPolarCoordinateOrder, METH_VARARGS},
    {"GetPolarCoordinateOrder", CurveAttributes_GetPolarCoordinateOrder, METH_VARARGS},
    {"SetAngleUnits", CurveAttributes_SetAngleUnits, METH_VARARGS},
    {"GetAngleUnits", CurveAttributes_GetAngleUnits, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
CurveAttributes_dealloc(PyObject *v)
{
   CurveAttributesObject *obj = (CurveAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *CurveAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyCurveAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "showLines") == 0)
        return CurveAttributes_GetShowLines(self, NULL);
    if(strcmp(name, "lineWidth") == 0)
        return CurveAttributes_GetLineWidth(self, NULL);
    if(strcmp(name, "showPoints") == 0)
        return CurveAttributes_GetShowPoints(self, NULL);
    if(strcmp(name, "symbol") == 0)
        return CurveAttributes_GetSymbol(self, NULL);
    if(strcmp(name, "Point") == 0)
        return PyInt_FromLong(long(CurveAttributes::Point));
    if(strcmp(name, "TriangleUp") == 0)
        return PyInt_FromLong(long(CurveAttributes::TriangleUp));
    if(strcmp(name, "TriangleDown") == 0)
        return PyInt_FromLong(long(CurveAttributes::TriangleDown));
    if(strcmp(name, "Square") == 0)
        return PyInt_FromLong(long(CurveAttributes::Square));
    if(strcmp(name, "Circle") == 0)
        return PyInt_FromLong(long(CurveAttributes::Circle));
    if(strcmp(name, "Plus") == 0)
        return PyInt_FromLong(long(CurveAttributes::Plus));
    if(strcmp(name, "X") == 0)
        return PyInt_FromLong(long(CurveAttributes::X));

    if(strcmp(name, "pointSize") == 0)
        return CurveAttributes_GetPointSize(self, NULL);
    if(strcmp(name, "pointFillMode") == 0)
        return CurveAttributes_GetPointFillMode(self, NULL);
    if(strcmp(name, "Static") == 0)
        return PyInt_FromLong(long(CurveAttributes::Static));
    if(strcmp(name, "Dynamic") == 0)
        return PyInt_FromLong(long(CurveAttributes::Dynamic));

    if(strcmp(name, "pointStride") == 0)
        return CurveAttributes_GetPointStride(self, NULL);
    if(strcmp(name, "symbolDensity") == 0)
        return CurveAttributes_GetSymbolDensity(self, NULL);
    if(strcmp(name, "curveColorSource") == 0)
        return CurveAttributes_GetCurveColorSource(self, NULL);
    if(strcmp(name, "Cycle") == 0)
        return PyInt_FromLong(long(CurveAttributes::Cycle));
    if(strcmp(name, "Custom") == 0)
        return PyInt_FromLong(long(CurveAttributes::Custom));

    if(strcmp(name, "curveColor") == 0)
        return CurveAttributes_GetCurveColor(self, NULL);
    if(strcmp(name, "showLegend") == 0)
        return CurveAttributes_GetShowLegend(self, NULL);
    if(strcmp(name, "showLabels") == 0)
        return CurveAttributes_GetShowLabels(self, NULL);
    if(strcmp(name, "designator") == 0)
        return CurveAttributes_GetDesignator(self, NULL);
    if(strcmp(name, "doBallTimeCue") == 0)
        return CurveAttributes_GetDoBallTimeCue(self, NULL);
    if(strcmp(name, "ballTimeCueColor") == 0)
        return CurveAttributes_GetBallTimeCueColor(self, NULL);
    if(strcmp(name, "timeCueBallSize") == 0)
        return CurveAttributes_GetTimeCueBallSize(self, NULL);
    if(strcmp(name, "doLineTimeCue") == 0)
        return CurveAttributes_GetDoLineTimeCue(self, NULL);
    if(strcmp(name, "lineTimeCueColor") == 0)
        return CurveAttributes_GetLineTimeCueColor(self, NULL);
    if(strcmp(name, "lineTimeCueWidth") == 0)
        return CurveAttributes_GetLineTimeCueWidth(self, NULL);
    if(strcmp(name, "doCropTimeCue") == 0)
        return CurveAttributes_GetDoCropTimeCue(self, NULL);
    if(strcmp(name, "timeForTimeCue") == 0)
        return CurveAttributes_GetTimeForTimeCue(self, NULL);
    if(strcmp(name, "fillMode") == 0)
        return CurveAttributes_GetFillMode(self, NULL);
    if(strcmp(name, "NoFill") == 0)
        return PyInt_FromLong(long(CurveAttributes::NoFill));
    if(strcmp(name, "Solid") == 0)
        return PyInt_FromLong(long(CurveAttributes::Solid));
    if(strcmp(name, "HorizontalGradient") == 0)
        return PyInt_FromLong(long(CurveAttributes::HorizontalGradient));
    if(strcmp(name, "VerticalGradient") == 0)
        return PyInt_FromLong(long(CurveAttributes::VerticalGradient));

    if(strcmp(name, "fillColor1") == 0)
        return CurveAttributes_GetFillColor1(self, NULL);
    if(strcmp(name, "fillColor2") == 0)
        return CurveAttributes_GetFillColor2(self, NULL);
    if(strcmp(name, "polarToCartesian") == 0)
        return CurveAttributes_GetPolarToCartesian(self, NULL);
    if(strcmp(name, "polarCoordinateOrder") == 0)
        return CurveAttributes_GetPolarCoordinateOrder(self, NULL);
    if(strcmp(name, "R_Theta") == 0)
        return PyInt_FromLong(long(CurveAttributes::R_Theta));
    if(strcmp(name, "Theta_R") == 0)
        return PyInt_FromLong(long(CurveAttributes::Theta_R));

    if(strcmp(name, "angleUnits") == 0)
        return CurveAttributes_GetAngleUnits(self, NULL);
    if(strcmp(name, "Radians") == 0)
        return PyInt_FromLong(long(CurveAttributes::Radians));
    if(strcmp(name, "Degrees") == 0)
        return PyInt_FromLong(long(CurveAttributes::Degrees));



    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyCurveAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyCurveAttributes_methods[i].ml_name),
                PyString_FromString(PyCurveAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyCurveAttributes_methods, self, name);
}

int
PyCurveAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "showLines") == 0)
        obj = CurveAttributes_SetShowLines(self, args);
    else if(strcmp(name, "lineWidth") == 0)
        obj = CurveAttributes_SetLineWidth(self, args);
    else if(strcmp(name, "showPoints") == 0)
        obj = CurveAttributes_SetShowPoints(self, args);
    else if(strcmp(name, "symbol") == 0)
        obj = CurveAttributes_SetSymbol(self, args);
    else if(strcmp(name, "pointSize") == 0)
        obj = CurveAttributes_SetPointSize(self, args);
    else if(strcmp(name, "pointFillMode") == 0)
        obj = CurveAttributes_SetPointFillMode(self, args);
    else if(strcmp(name, "pointStride") == 0)
        obj = CurveAttributes_SetPointStride(self, args);
    else if(strcmp(name, "symbolDensity") == 0)
        obj = CurveAttributes_SetSymbolDensity(self, args);
    else if(strcmp(name, "curveColorSource") == 0)
        obj = CurveAttributes_SetCurveColorSource(self, args);
    else if(strcmp(name, "curveColor") == 0)
        obj = CurveAttributes_SetCurveColor(self, args);
    else if(strcmp(name, "showLegend") == 0)
        obj = CurveAttributes_SetShowLegend(self, args);
    else if(strcmp(name, "showLabels") == 0)
        obj = CurveAttributes_SetShowLabels(self, args);
    else if(strcmp(name, "designator") == 0)
        obj = CurveAttributes_SetDesignator(self, args);
    else if(strcmp(name, "doBallTimeCue") == 0)
        obj = CurveAttributes_SetDoBallTimeCue(self, args);
    else if(strcmp(name, "ballTimeCueColor") == 0)
        obj = CurveAttributes_SetBallTimeCueColor(self, args);
    else if(strcmp(name, "timeCueBallSize") == 0)
        obj = CurveAttributes_SetTimeCueBallSize(self, args);
    else if(strcmp(name, "doLineTimeCue") == 0)
        obj = CurveAttributes_SetDoLineTimeCue(self, args);
    else if(strcmp(name, "lineTimeCueColor") == 0)
        obj = CurveAttributes_SetLineTimeCueColor(self, args);
    else if(strcmp(name, "lineTimeCueWidth") == 0)
        obj = CurveAttributes_SetLineTimeCueWidth(self, args);
    else if(strcmp(name, "doCropTimeCue") == 0)
        obj = CurveAttributes_SetDoCropTimeCue(self, args);
    else if(strcmp(name, "timeForTimeCue") == 0)
        obj = CurveAttributes_SetTimeForTimeCue(self, args);
    else if(strcmp(name, "fillMode") == 0)
        obj = CurveAttributes_SetFillMode(self, args);
    else if(strcmp(name, "fillColor1") == 0)
        obj = CurveAttributes_SetFillColor1(self, args);
    else if(strcmp(name, "fillColor2") == 0)
        obj = CurveAttributes_SetFillColor2(self, args);
    else if(strcmp(name, "polarToCartesian") == 0)
        obj = CurveAttributes_SetPolarToCartesian(self, args);
    else if(strcmp(name, "polarCoordinateOrder") == 0)
        obj = CurveAttributes_SetPolarCoordinateOrder(self, args);
    else if(strcmp(name, "angleUnits") == 0)
        obj = CurveAttributes_SetAngleUnits(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
CurveAttributes_print(PyObject *v, FILE *fp, int flags)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)v;
    fprintf(fp, "%s", PyCurveAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
CurveAttributes_str(PyObject *v)
{
    CurveAttributesObject *obj = (CurveAttributesObject *)v;
    return PyString_FromString(PyCurveAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *CurveAttributes_Purpose = "Attributes for the xy plot";
#else
static char *CurveAttributes_Purpose = "Attributes for the xy plot";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(CurveAttributesType,         \
                  "CurveAttributes",           \
                  CurveAttributesObject,       \
                  CurveAttributes_dealloc,     \
                  CurveAttributes_print,       \
                  PyCurveAttributes_getattr,   \
                  PyCurveAttributes_setattr,   \
                  CurveAttributes_str,         \
                  CurveAttributes_Purpose,     \
                  CurveAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
CurveAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &CurveAttributesType
         || Py_TYPE(other) != &CurveAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    CurveAttributes *a = ((CurveAttributesObject *)self)->data;
    CurveAttributes *b = ((CurveAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static CurveAttributes *defaultAtts = 0;
static CurveAttributes *currentAtts = 0;

static PyObject *
NewCurveAttributes(int useCurrent)
{
    CurveAttributesObject *newObject;
    newObject = PyObject_NEW(CurveAttributesObject, &CurveAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new CurveAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new CurveAttributes(*defaultAtts);
    else
        newObject->data = new CurveAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapCurveAttributes(const CurveAttributes *attr)
{
    CurveAttributesObject *newObject;
    newObject = PyObject_NEW(CurveAttributesObject, &CurveAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (CurveAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
CurveAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewCurveAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef CurveAttributesMethods[] = {
    {"CurveAttributes", CurveAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *CurveAttributesObserver = 0;

std::string
PyCurveAttributes_GetLogString()
{
    std::string s("CurveAtts = CurveAttributes()\n");
    if(currentAtts != 0)
        s += PyCurveAttributes_ToString(currentAtts, "CurveAtts.", true);
    return s;
}

static void
PyCurveAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("CurveAtts = CurveAttributes()\n");
        s += PyCurveAttributes_ToString(currentAtts, "CurveAtts.", true);
        cb(s);
    }
}

void
PyCurveAttributes_StartUp(CurveAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyCurveAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(CurveAttributesObserver == 0)
    {
        CurveAttributesObserver = new ObserverToCallback(subj,
            PyCurveAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyCurveAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete CurveAttributesObserver;
    CurveAttributesObserver = 0;
}

PyMethodDef *
PyCurveAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return CurveAttributesMethods;
}

bool
PyCurveAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &CurveAttributesType);
}

CurveAttributes *
PyCurveAttributes_FromPyObject(PyObject *obj)
{
    CurveAttributesObject *obj2 = (CurveAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyCurveAttributes_New()
{
    return NewCurveAttributes(0);
}

PyObject *
PyCurveAttributes_Wrap(const CurveAttributes *attr)
{
    return WrapCurveAttributes(attr);
}

void
PyCurveAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    CurveAttributesObject *obj2 = (CurveAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyCurveAttributes_SetDefaults(const CurveAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new CurveAttributes(*atts);
}

